// modules/aiAgent/aiAgent.controller.ts

import { Provide, Inject } from '@midwayjs/core';
import { CoolController, BaseController, BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Column, Entity, PrimaryGeneratedColumn, CreateDateColumn, Repository } from 'typeorm';

/**
 * AI智能体表
 */
@Entity('ai_agent')
export class AiAgentEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '头像URL' })
  avatar: string;

  @Column({ type: 'varchar', length: 512, nullable: true, comment: '简介' })
  bio: string;

  @Column({ type: 'varchar', length: 512, nullable: true, comment: '开场白' })
  welcome: string;

  @Column({ type: 'text', nullable: true, comment: '预设问题' })
  presetQuestions: string;

  @Column({ type: 'jsonb', nullable: true, comment: '用户输入变量(JSON)' })
  userVariables: object;

  @Column({ type: 'bool', default: false, comment: '是否发布到智能广场' })
  isPublished: boolean;

  @Column({ type: 'bool', default: false, comment: '是否设为首页智能体' })
  isHome: boolean;

  @Column({ type: 'int', comment: '所属分站ID' })
  subsiteId: number;

  @CreateDateColumn({ type: 'timestamp', comment: '创建时间' })
  createTime: Date;

  // 新增字段：token
  @Column({ type: 'varchar', length: 255, nullable: true, comment: 'Token' })
  token: string;

  // 新增字段：botId
  @Column({ type: 'varchar', length: 128, nullable: true, comment: 'Bot唯一标识符' })
  botId: string;

  // 新增字段：siteId
  @Column({ type: 'int', comment: '所属分站ID' })
  siteId: number;  // 分站ID

  // 新增字段：预设输入项
  @Column({ type: 'jsonb', nullable: true, comment: '预设输入项，智能体会话初始时可以快捷点击的输入' })
  presetInputs: string[];  // 存储快捷输入的字符串数组
}

/**
 * AI智能体控制器
 */
@Provide()
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: AiAgentEntity,
})
export class AiAgentController extends BaseController {
  // 如需扩展自定义接口，可在这里补充
  // @Post('/custom')
  // async custom(@Body() body) {
  //   return this.ok(await this.aiAgentService.someMethod(body));
  // }
}
